#include "widget.h"
#include "ui_widget.h"
#include <QShortcut>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QShortcut* pageup = new QShortcut(this);
    pageup->setKey(QKeySequence("+"));
    connect(pageup, &QShortcut::activated, this, &Widget::Add);

    QShortcut* pagedown = new QShortcut(this);
    pagedown->setKey(QKeySequence("-"));
    connect(pageup, &QShortcut::activated, this, &Widget::Sub);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_horizontalSlider_valueChanged(int value)
{
    ui->label->setText(QString::number(value));
    QRect rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), value, rect.height());
}

void Widget::on_verticalSlider_valueChanged(int value)
{
    QRect rect = this->geometry();
    this->setGeometry(rect.x(), rect.y(), rect.width(), value);
}

void Widget::Add()
{
    int val = ui->verticalSlider->value();
    ui->horizontalSlider->setValue(val + 20);
}

void Widget::Sub()
{
    int val = ui->verticalSlider->value();
    ui->horizontalSlider->setValue(val - 20);
}
